package com.jellyfishumbrella.GL;

import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.LinkedHashMap;
import static org.lwjgl.opengl.GL11.*;

import org.newdawn.slick.opengl.Texture;
import org.newdawn.slick.opengl.TextureLoader;
import org.newdawn.slick.util.ResourceLoader;

public class TextureHash extends LinkedHashMap<String, Texture> {
	public final String PATH = "res/images/";
	public final String EXT = ".png";
	public void loadTexture(String filename) {
		if (!containsKey(filename)) {
			Texture texture;
			try {
				texture = TextureLoader.getTexture("PNG", ResourceLoader.getResourceAsStream(PATH + filename + EXT));
				System.out.println("Texture loaded: " + filename);
				System.out.println(">> Image width: " + texture.getImageWidth());
				System.out.println(">> Image height: " + texture.getImageHeight());
				System.out.println(">> hasAlpha? : " + texture.hasAlpha());
				System.out.println(">> Texture ID: " + texture.getTextureID());
				texture.bind();
				
				glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER, GL_NEAREST);
				glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER, GL_NEAREST);

				put(filename, texture);
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
	}
}
